From 34a73a3e9a34b8b609ce900a2adcdaad5454717f Mon Sep 17 00:00:00 2001 From: Krinkle Date: Sat, 30 Jul 2011 07:38:01 +0000 Subject: [PATCH] Adding unit test for bug 27427. Currently broken. Fix (provided by Michael M. through BugZilla) will be committed afterwards. * (bug 27427) mw.util.getParamValue shouldn't return value from hash even if param is only present in hash --- CREDITS | 1 + .../suites/resources/mediawiki/mediawiki.util.js | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CREDITS b/CREDITS index 25e5d2a5c7..06108ad771 100644 --- a/CREDITS +++ b/CREDITS @@ -122,6 +122,7 @@ following names for their contribution to the product. * Max Sikström * Michael Dale * Michael De La Rue +* Michael M. * Michael Walsh * Mike Horvath * Mormegil diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.util.js b/tests/qunit/suites/resources/mediawiki/mediawiki.util.js index 7fb8fe9db1..4dfb0dcb35 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.util.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.util.js @@ -107,12 +107,15 @@ test( 'toggleToc', function() { }); test( 'getParamValue', function() { - expect(2); + expect(3); + + var url1 = 'http://mediawiki.org/?foo=wrong&foo=right#&foo=bad'; - var url = 'http://mediawiki.org/?foo=wrong&foo=right#&foo=bad'; + equal( mw.util.getParamValue( 'foo', url1 ), 'right', 'Use latest one, ignore hash' ); + strictEqual( mw.util.getParamValue( 'bar', url1 ), null, 'Return null when not found' ); - equal( mw.util.getParamValue( 'foo', url ), 'right', 'Use latest one, ignore hash' ); - strictEqual( mw.util.getParamValue( 'bar', url ), null, 'Return null when not found' ); + var url2 = 'http://mediawiki.org/#&foo=bad'; + strictEqual( mw.util.getParamValue( 'foo', url2 ), null, 'Ignore hash if param is not in querystring but in hash (bug 27427)' ); }); test( 'tooltipAccessKey', function() { -- 2.20.1